<template>
	<view class="p-top24">
		<view class="Wrapper">
			<view class="list">
				<view class="listNum">
					<text class="color_33 size28">预约号</text>
					<text class="black size60 bold">{{line_up_detail.num}}</text>
					<text class="color_33 size28">就餐人数 {{line_up_detail.people}} 位</text>
				</view>
				<view class="Box">
					<view class="UserTel">
						<view class="User">
							<image :src="$imgUrls(member_info.v_headimg)" mode="aspectFill" class="UserImG">
							</image>
							<view class="d-flex f-column flex-1  hidden">
								<text class="color_33 size28 ellipsis">{{member_info.v_name}}</text>
								<text class="color_33 size26">{{member_info.v_tel}}</text>
							</view>
						</view>
						<view class="iconfont icon-dadianhua color_169 size48 padding20 "
							@click="$common.Tel(member_info.v_tel)"></view>
					</view>

					<view class="row j-sb a-center">
						<view class="d-flex a-center">
							<view class="oper expired" v-if="line_up_detail.state == 3">已撤销</view>
							<view class="oper expired" v-if="line_up_detail.state == 2">已过期</view>
							<view class="oper Make" v-if="line_up_detail.state == 1">已应约</view>
						</view>
						<view class="d-flex a-center" @click.stop="toUser">
							<text class="h6 black">用户账户</text>
							<text class="iconfont icon-xiangyouxiayiye black h6"></text>
						</view>

					</view>
				</view>
			</view>

		</view>




		<view class="list">
			<view class="item" v-for="(item,i) in list" :key='i' :class="{active: itemCurrent == i}"
				@click="toUrl('/pages/order/detail?id='+item.order_id)">
				<view class="no flex-box flex-between">
					<view class="code">单号：{{ item.order_code }}</view>
					<text v-if='item.state == 0'>未支付</text>
					<text v-if='item.state == 1 && item.delivery == 1'>待发货</text>
					<text v-if='item.state == 1 && item.delivery == 2'>待备货</text>
					<text v-if='item.state == 2 && item.delivery == 1'>已发货</text>
					<text v-if='item.state == 2 && item.delivery == 2'>待取货</text>
					<text v-if='item.state == 3'>待确认</text>
					<text v-if='item.state == 4' class='st1'>待评价</text>
					<text v-if='item.state == 5'>已评价</text>
					<text v-if='item.state == 6'>退款中</text>
					<text v-if='item.state == 96' class='st1'>已退款</text>
					<text v-if='item.state == 97'>已失效</text>
					<text v-if='item.state == 98'>已取消</text>
				</view>
				<view v-if="item.siteName">宴会名称：{{ item.siteName }}</view>
				<view v-if="item.table_name">桌号：{{ item.table_name }}</view>
				<view v-if="item.open_date">开宴时间：{{ item.open_date }}</view>

				<view class="flex-box flex-between">
					<view>{{ item.add_time }}</view>
					<view>
						<text class='tag' v-if='item.type == 1'>特价</text>
						<text class='tag' v-if='item.type == 2'>团购</text>
						<text class='log' v-if='item.delivery == 1 && item.state == 3'>物流</text>
						<text class='log' v-if='item.delivery == 2'>自提</text>
					</view>
				</view>
				<view>{{ item.uname }}（{{ item.utel }}）</view>
				<view v-if='item.address'>{{ item.address }}</view>
				<view class="remarks" v-if='item.remarks'>{{ item.remarks }}</view>
				<view class="btns flex-box align-center">
					<text class="iconfont icon-down" v-if='item.remarks'
						@click.stop="itemCurrent = itemCurrent==i?-1:i"></text>
					<view class="flex-box flex">
						<view class="btn" @click.stop="contact(item)">联系客户</view>
						<view class="btn1" v-if='item.state == 1 && item.delivery == 1'
							@click.stop="toUrl('/pages/order/sendOut?order_id='+item.order_id)">去发货</view>
						<view class="btn1" v-if='item.state == 6' @click.stop="backOff(item.order_id,i)">确定退单</view>
						<view class="btn1" v-if='item.state == 1 && item.delivery == 2'
							@click.stop="Stockup(item.order_id,i)">备货完成</view>
						<!-- <view class="btn1" v-if='item.state == 2'>扫码核销</view> -->
					</view>
				</view>
			</view>
		</view>

		<view class="row j-centert m-top100" v-if="!list.length">
			<u-empty mode="order" text="暂无相关信息"></u-empty>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				shop_id: '',
				id: '',
				line_up_detail: '',
				member_info: '',
				itemCurrent: -1,
				list: []
			}
		},
		onLoad(opt) {
			if (opt.id) this.id = opt.id
			if (opt.shop_id) this.shop_id = opt.shop_id
			this.lineUpDetail()
		},
		methods: {
			...mapMutations(['getVid']),
			lineUpDetail() {
				this.$http.get({
					url: '/singleSaleManageApi/lineUpDetail',
					data: {
						shop_id: this.shop_id,
						id: this.id
					}
				}).then(res => {
					if (res.code != 200) return this.$Toast(res.msg)
					const result = res.data
					this.line_up_detail = result.line_up_detail
					this.member_info = result.member_info
					this.list = result.today_orders || []
				})
			},

			toUser() {
				this.getVid(this.member_info.v_id)
				this.toUrl(`/Money/userMoney`)
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: $page;
	}
</style>
<style lang="scss" scoped>
	.Wrapper {
		width: 710rpx;
		margin: 0 auto;

		.list {
			width: 100%;
			min-height: 200rpx;
			background-color: #ffffff;
			border-radius: 10rpx;
			box-sizing: border-box;
			display: flex;

			.listNum {
				width: 230rpx;
				min-height: 200rpx;
				padding: 10rpx;
				border-right: 1px solid $page;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-evenly;
				margin-right: 10rpx;
			}

			.Box {
				width: 470rpx;
				padding: 10rpx;
				min-height: 200rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.UserTel {
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.User {
						flex: 1;
						display: flex;
						align-items: center;
						overflow: hidden;

						.UserImG {
							width: 70rpx;
							height: 70rpx;
							display: block;
							border-radius: 6rpx;
							margin-right: 10rpx;
						}
					}
				}

				.operate {
					width: 100%;
					display: grid;
					grid-template-columns: repeat(3, 1fr);
					grid-gap: 20rpx;

				}

				.oper {
					height: 58rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					color: #fff;
					font-size: 26rpx;
					border-radius: 10rpx;
					padding: 0 24rpx;
				}

				.Call {
					background-color: #169bd5;
				}

				.expired {
					background-color: #ccc;
				}

				.Make {
					background-color: #006633;
				}

			}
		}
	}

	.list {
		padding: $page-space;

		.item {
			background-color: #FFFFFF;
			padding: 24rpx $page-space 0;
			border-radius: $border-radius-sm;
			margin-bottom: $page-space;
			position: relative;

			&::before {
				content: '';
				position: absolute;
				width: 4rpx;
				height: 24rpx;
				background-color: $uni-color-primary;
				left: 0;
				top: 32rpx;
				border-radius: 0 4rpx 4rpx 0;
			}

			text {
				font-size: 28rpx;
				color: #FF6C6C;
			}

			.st1 {
				color: #999999;
			}

			.no {
				view {
					font-weight: 600;
				}
			}

			>view {
				margin-bottom: 15rpx;
			}

			.log {
				background-color: #90CFFF;
				color: white;
				font-size: 24rpx;
				padding: 2rpx 6rpx;
				border-radius: 4rpx;
				margin-left: 20rpx;
			}

			.tag {
				background-color: #F6B081;
				color: white;
				font-size: 24rpx;
				padding: 2rpx 6rpx;
				border-radius: 4rpx;

			}

			.remarks {
				color: #999999;
				margin-bottom: 20rpx;
				height: 0;
				overflow: hidden;
				transition: all .3s;
			}

			&.active {
				.remarks {
					height: auto;
				}

				.icon-down {
					transform: rotate(180deg);
				}
			}

			.btns {
				margin-left: -$page-space;
				margin-right: -$page-space;
				height: 104rpx;
				border-top: 1px solid #F5F5F5;
				padding: 0 $page-space 0 0;

				.icon-down {
					color: #999999;
					font-size: 26rpx;
					padding: 20rpx $page-space;
					transition: all .2s;
				}

				>view {
					justify-content: flex-end;
					flex-wrap: wrap;

					.btn {
						margin-left: 20rpx;
						line-height: 56rpx;
						color: #999999;
						border: 1px solid #afafaf;
						border-radius: 56rpx;
						padding: 0 24rpx;
					}

					.btn1 {
						margin-left: 20rpx;
						line-height: 56rpx;
						color: #FFFFFF;
						border: 1px solid $uni-color-primary;
						background-color: $uni-color-primary;
						border-radius: 56rpx;
						padding: 0 24rpx;
					}
				}
			}
		}
	}
</style>